package com.xiaofan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

/**
 * @author 晓帆
 * @version 1.0
 **/
@RestController
@RequestMapping("i18n")
public class I18nController {
    @Autowired
    MessageSource messageSource;
    @RequestMapping("get/{key}")
    public void getKey(@PathVariable("key") String key, Locale locale){
        String message = messageSource.getMessage(key, null, locale);
        System.out.println(message);
    }
}
